﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.Mvc.ViewPage<PostRssViewModel>" %>

<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel>
        <title><%= Model.BlogTitle %></title>
        <description><%= Model.BlogDescription %></description>
        <link><%= Url.AbsolutePath(Url.Home()) %></link>
        <language><%=Model.Language %></language>
        <copyright><%= Model.Copyright %></copyright>
        <managingEditor><%= Model.ManagingEditor %></managingEditor>
        <webMaster><%= Model.WebMaster %></webMaster>
        <%  foreach (var post in Model.Posts)
            {
                string postUrl = Url.AbsolutePath(Url.PostDetails(post.Id)); %>
        <item>
            <title><%=Html.Encode(post.Title)%></title>
            <link><%=postUrl %></link>
            <description>
                
                <%  bool isShort = false;
                    string content = string.Empty;
                    int num = post.PostContent.IndexOf("<!--short-->");
                    if (num != -1)
                    {
                        isShort = true;
                        content = post.PostContent.Remove(num);
                    }
                    else
                    {
                        content = post.PostContent;
                    }
                %>
                <%=Html.Encode(content)%>
            </description>
            <dc:creator><%= Model.WebMaster +" - "+ Html.Encode(post.Author)%></dc:creator>
            <guid isPermaLink="true"><%=postUrl %></guid>
            <pubDate><%=post.PublishedDate.Value.ToString()%></pubDate>
            <% foreach (var item in post.PostCategories)
               {
	         %>
                <category><%= item.Name %></category>
            <% } %>
        </item>
<%} %>
    </channel>
</rss>
